import api from '../../../fetch/api'

export default {
    data() {
        return {
            bigImgPath: ''
        }
    },
    created() {
        this.getItemList();
    },
    methods: {
        getList() {
            this.getItemList(this.searchParams);
        },
        showBigImgModal(name, path) {
            this.bigImgPath = path;
            this.toOpenImgModal(name, path);
        },
        //获取列表
        getItemList(aparams) {
            let self = this,
                params = {
                    page: this.pageNumber,
                    rp: this.pageSize
                };
            params = $.extend({}, params, aparams);
            // API.coupon.GetTraderListData(params)
            api.fetchGet('/trader/getListByPage.do', params)
                .then(res => {
                    console.log('getListResult', res)
                    let data = res.data,
                        list = data.rows;
                    self.tbodysInfo = list;
                    self.total = data.total;
                }, err => { })
        },
        showContent(content) {
            console.log(content);
            let _this = this;
            _this.contentData=content;
            _this.toOpenModal('contentModal')
        },
        function_comfirm(type, id) {
            console.log('type, id', type, id)
            if (this.selectionList.length > 0 || id) {
                var idList = [];
                var params = {};
                if (id) {
                    params.id = id
                } else {
                    console.log('this.selectionList', this.selectionList, type);
                    this.selectionList.forEach(function (element) {
                        idList.push(element.id)
                    }, this);
                    params.ids = idList.join(',');
                }
                switch (type) {
                    case 'DT': //删除优惠
                        params.validStatus = 'DEL';
                        this.function_comfirm_callback(params)
                        break;

                    default:
                        break;
                }
            }
        },
        function_comfirm_callback(params) {
            api.fetchGet('/trader/delTraderSuggest.do', params)
                .then(res => {
                    console.log('function_comfirm_callback', res)
                    // icon: 0:普通提示 1：正确的提示 2： 错误提示
                    // time: 不填默认1000ms
                    this.showToast(res.message, 1, 2000)
                    this.getItemList();

                }, err => {
                    // this.showToast(err.data.message, 2, 5000)
                })
        },
        exportData() {
            let self = this;
            let params = {
            };
            params = $.extend({}, params, this.searchParams);
            self.showDialog("确认导出该报表?", '', function () {
                self.toExport('trader/exportTraderSuggest.do', params)
            })
        }
    }
}